﻿@model List<NFine.Domain._03_Entity.Weixin.CompanyEntity>
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>公司列表</title>
    <link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/1.0.1/css/jquery-weui.min.css">
    <link rel="stylesheet" href="//cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
    <link href="~/Content/M/css/list.css" rel="stylesheet" />
    <script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/jquery-weui/1.0.1/js/jquery-weui.min.js"></script>
    <style>
        .divJoin {
            height:2rem; position:fixed; bottom:0;width:100%; left:0; text-align:center; background-color:#44ac3d; line-height:2rem;
        }
       
    </style>
</head>
<body>
    <div class="weui-search-bar weui-search-bar_focusing" id="searchBar">
        <form class="weui-search-bar__form" action="Index">
            <div class="weui-search-bar__box">
                <i class="weui-icon-search"></i>
                <input type="search" class="weui-search-bar__input" id="searchInput" name="searchInput" placeholder="请输入您要搜索的公司" value="@ViewData["search"]"  >
                <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
            </div>
            <label class="weui-search-bar__label" id="searchText">
                <i class="weui-icon-search"></i>
                <span>搜索</span>
            </label>
        </form>
    </div>

    <div class="weui-panel weui-panel_access" style="margin-top:auto">
        @{
            var list = (List<NFine.Domain._03_Entity.Weixin.CompanyEntity>)Model;
            if (list != null && list.Count > 0)
            {
                 <div class="weui-panel__bd"  id="divCompany">
                    @foreach(var com in list)
                    {
                        <a href="tel:@com.ContactPhone" class="weui-media-box weui-media-box_appmsg" style="padding:10px 5px 10px 10px;">
                            <div class="weui-media-box__hd" style="width:100px;height:100px">
                                <img class="weui-media-box__thumb" src="@com.Logo" style="width:100%;height:100%" />
                            </div>
                            <div class="weui-media-box__bd">
                                <h4 class="weui-media-box__title">@com.Name</h4>
                                <div class="weui-media-box__desc" style="line-height:1.6">联&nbsp; 系&nbsp; 人： @com.Contact (@com.ContactPhone)</div>
                                <div class="weui-media-box__desc" style="line-height:1.6">经营项目：@com.BusinessProject</div>
                                <div class="weui-media-box__desc" style="line-height:1.6">公司地址：@com.Address</div>
                            </div>
                        </a>
                    }
              </div>
               
            }
            else
            {
                <div style="text-align:center;margin:0.5rem auto">
                    暂无更多公司，欢迎加入
                </div>
            }
        }
      
    </div>
   @if (list.Count == 10)
    {
    <div class="weui-loadmore" id="divMore" style="margin-top:0.5rem;">
        <i class="weui-loading"></i>
        <span class="weui-loadmore__tips">上拉加载更多</span>
    </div>
    }
    else
    {
    <div class="weui-footer" style="margin-top:0.5rem;">--加载完毕--</div>
    }
    @*<div style="height:50px"></div>
    <div class="divJoin">
        <div style="width:100%;height:2rem; " >
            <a href="join" class="weui-btn weui-btn_primary">
                申请加入
            </a>
        </div>
    </div>*@
</body>
</html>

<script type="text/javascript">
    $("#searchInput").focus(function () {
        $("#searchBar").addClass("weui-search-bar_focusing");
    });
    var loading = false;  //状态标记
    var _page = 0;
    $(document).ready(function () {
        if (@list.Count == 10)
           { $(document.body).infinite().on("infinite", function () {
                if (loading) return;
                loading = true;
                setTimeout(function () {
                    _page++;
                    initMoreData();
                    loading = false;
                }, 1000);
            });
     }
    });
    function initMoreData() {
        $.ajax({
            url: "getMore?start=" + _page + "&searchInput=@ViewData["search"]",
            dataType: 'json',
            type: 'post',
            success: function (_data) {
                var _html = '';
                for (var i = 0, len = _data.length; i < len; i++) {
                    var com = _data[i];
                    if (com.BusinessProject == null)
                        com.BusinessProject = "";
                    _html += ' <a href="tel:'+com.ContactPhone+'" class="weui-media-box weui-media-box_appmsg" style="padding:10px 5px 10px 10px;">';
                    _html += '<div class="weui-media-box__hd" style="width:100px;height:100px">';
                    _html += '<img class="weui-media-box__thumb" src="' + com.Logo + '" style="width:100%;height:100%" />';
                    _html += '</div>';
                    _html += '<div class="weui-media-box__bd">';
                    _html += '<h4 class="weui-media-box__title">' + com.Name + '</h4>';
                    _html += '<div class="weui-media-box__desc" style="line-height:1.6">联&nbsp; 系&nbsp; 人： ' + com.Contact + '(' + com.ContactPhone + ')</div>';
                    _html += '<div class="weui-media-box__desc" style="line-height:1.6">经营项目： ' + com.BusinessProject + '</div>';
                    _html += '<div class="weui-media-box__desc" style="line-height:1.6">公司地址： ' + com.Address + '</div>';
                    _html += '</div>';
                    _html += '</a>';
                }
                $("#divCompany").append(_html);
                if (_data.length < 10) {
                    _html = '  <div class="weui-footer" style="margin-top:0.5rem;">--加载完毕--</div>';
                    $(document.body).destroyInfinite();
                    $("#divMore").hide();
                    $("body").append(_html);
                }
            }
        }
        );
    };
    </script>
